<template>
    <div>
    <el-upload
            :show-file-list="false"
            :before-upload="beforeUpload"
            :on-success="onSuccess"
            :on-error="onError"
            :disabled="importDisabled"
            style="display: inline-flex;margin-right: 10px;"
            :action="'http://localhost:8080/data/import?uid='+store.auth.idd">
        <el-button size="small" :disabled="importDisabled" type="success">
            <el-icon class="el-icon--left"><Upload /></el-icon>{{importDataText}}
            <div slot="tip" class="el-upload__tip">说明：只能上传doc或docx文件</div>
        </el-button>
    </el-upload>
    <el-button @click="look">预览</el-button>
    述职报告状态：<p style="color:red">{{state}}</p>
    </div>
    <div>
    <el-upload
            :show-file-list="false"
            :before-upload="beforeUpload1"
            :on-success="onSuccess1"
            :on-error="onError1"
            :disabled="importDisabled1"
            style="display: inline-flex;margin-right: 10px;"
            :action="'http://localhost:8080/data/importL?uid='+store.auth.idd">
        <el-button size="small" :disabled="importDisabled1" type="success">
            <el-icon class="el-icon--left"><Upload /></el-icon>{{importDataText1}}
            <div slot="tip" class="el-upload__tip">说明：只能上传doc或docx文件</div>
        </el-button>
    </el-upload>
    <el-button @click="lookL">预览</el-button>
    领导班子报告状态：<p style="color:red">{{state1}}</p>
    </div>
</template>
<script setup>
import { get,post } from '@/utils/request.js'
import {ElMessage} from 'element-plus'
import router from '@/router'
import { ref,onMounted } from 'vue'
import {userStore} from '@/stores/counter.js'
import {Upload} from '@element-plus/icons-vue'
import moment from 'moment'

const importDataText=ref('上传述职报告')
const importDisabled=ref(false)
const importDataText1=ref('上传领导板班子报告')
const importDisabled1=ref(false)
const store=userStore()
const datas=ref([])
const state=ref('')
const state1=ref('')

post('/user/byMiddel',
{uid:store.auth.idd},(message)=>{
if(message.status===0) state.value='未上传'
else if(message.status===1) {state.value='审核通过'
importDisabled.value = true;
}
else if(message.status===2) state.value='待审核'
else if(message.status===3) state.value='审核不通过'
},(message)=>{
ElMessage.warning(message);
})

post('/user/byLeaderShip',
{uid:store.auth.idd},(message)=>{
if(message.status===0) state1.value='未上传'
else if(message.status===1) {state1.value='审核通过'
importDisabled1.value = true;
}
else if(message.status===2) state1.value='待审核'
else if(message.status===3) state1.value='审核不通过'
},(message)=>{
ElMessage.warning(message);
})

const onError=()=>{
                importDataText.value = '上传述职报告';
                importDisabled.value = false;
                 ElMessage.warning("上传失败！");
            }
            const onSuccess=()=> {
            	// 成功后文本修改为原来的导入数据
                importDataText.value = '上传述职报告';
                // 将上传组件改为允许使用
                importDisabled.value = false;
                // 调用刷新数据的方法

                // message 弹出消息
                ElMessage.success("上传成功！");
            }
const beforeUpload=()=> {
            	// 将文本修改为正在导入
                importDataText.value = '正在上传';
                // 将其上传组件暂时禁用
                importDisabled.value = true;
            }

            const onError1=()=>{
                importDataText1.value = '上传领导班子报告';
                importDisabled1.value = false;
                 ElMessage.warning("上传失败！");
            }
            const onSuccess1=()=> {
            	// 成功后文本修改为原来的导入数据
                importDataText1.value = '上传领导班子报告';
                // 将上传组件改为允许使用
                importDisabled1.value = false;
                // 调用刷新数据的方法

                // message 弹出消息
                ElMessage.success("上传成功！");
            }
const beforeUpload1=()=> {
            	// 将文本修改为正在导入
                importDataText1.value = '正在上传';
                // 将其上传组件暂时禁用
                importDisabled1.value = true;
            }

const look=()=>{
window.open('http://localhost:8080/user/look?uid='+store.auth.idd)
}

const lookL=()=>{
window.open('http://localhost:8080/user/lookL?uid='+store.auth.idd)
}
</script>
<style scoped>



</style>